// app.js nodejs原生路由简单例子
var http = require("http");
var fs = require("fs");
http
    .createServer((req, res) => {
        switch (req.url) {
            case "/hello":
                res.write("hello");
                res.end();
                break;
            case "/hehe":
                res.write("hehe");
                res.end();
                break;
            case "/my":
                fs.readFile("data.json", (error, data) => {
                    if (error) throw error;
                    res.write(data);
                    res.end();
                });
                break;
            default:
                res.write("this is home");
                res.end();
                break;
        }
    })
    .listen(3000, "localhost", () => {
        console.log("服务器运行在：http://localhost:3000");
    });